﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Display.UpgradesUI {
    import flash.events.*;
    import flash.display.*;
    import flash.geom.*;
    import flash.utils.*;
    import Display.DialogUI.*;
    import Classes.*;
    import Classes.util.*;
    import com.greensock.*;

    public class BusinessUpgradesDialog extends GenericDialog {

        protected var m_building:MapResource;
        protected var m_finishCheckCB:Function;
        protected var m_finishCB:Function;
        protected var m_buyHandler:Function;

        public function BusinessUpgradesDialog(_arg1:MapResource, _arg2:Function, _arg3:Function, _arg4:Function){
            this.m_building = _arg1;
            this.m_finishCheckCB = _arg2;
            this.m_finishCB = _arg3;
            this.m_buyHandler = _arg4;
            super("", "", 0, null, "BusinessUpgradesUI", "", false);
        }
        override protected function createDialogView(_arg1:Dictionary):GenericDialogView{
            return (new BusinessUpgradesDialogView(this.m_building, this.m_finishCheckCB, this.m_finishCB, this.m_buyHandler));
        }
        override protected function loadAssets():void{
            Global.delayedAssets.get(DelayedAssetLoader.BIZ_UPGRADES_ASSETS, makeAssets);
        }
        override protected function createAssetDict():Dictionary{
            UpgradesCommonAssets.bizupsAssetDict["dialogBG"] = (new m_comObject.upgrades_bg() as DisplayObject);
            UpgradesCommonAssets.bizupsAssetDict["blankPortrait"] = m_comObject.upgrades_portrait_missing;
            UpgradesCommonAssets.bizupsAssetDict["currentCard"] = m_comObject.upgrades_level_card_current;
            UpgradesCommonAssets.bizupsAssetDict["upgradeCard"] = m_comObject.upgrades_level_card_upgrade;
            UpgradesCommonAssets.bizupsAssetDict["upgradeBarBG"] = m_comObject.upgrades_bar_bg;
            UpgradesCommonAssets.bizupsAssetDict["upgradeBar"] = m_comObject.upgrades_bar;
            UpgradesCommonAssets.bizupsAssetDict["checkMark"] = m_comObject.upgrades_checkmark;
            UpgradesCommonAssets.bizupsAssetDict["arrow"] = m_comObject.upgrades_mastery_arrow;
            UpgradesCommonAssets.bizupsAssetDict["verticleRule"] = m_comObject.upgrades_mastery_verticle_rule;
            UpgradesCommonAssets.bizupsAssetDict["star"] = m_comObject.upgrades_mastery_star_big;
            UpgradesCommonAssets.bizupsAssetDict["divider"] = m_comObject.upgrades_divider_gradient;
            return (UpgradesCommonAssets.bizupsAssetDict);
        }
        override protected function showTween():void{
            this.mouseEnabled = (this.mouseChildren = false);
            this.centerPopup();
            m_content.alpha = 0;
            m_content.scaleX = (m_content.scaleY = 1);
            TweenLite.to(m_content, TWEEN_TIME, {
                alpha:1,
                onComplete:onShowComplete
            });
        }
        override public function centerPopup():void{
            var _local1:Rectangle;
            var _local2:Point;
            var _local3:Number;
            if (parent){
                _local1 = Global.hud.getRect(parent);
                _local2 = new Point(((Global.stage.stageWidth - m_jpanel.width) / 2), ((Global.stage.stageHeight - m_jpanel.height) / 2));
                _local3 = Global.hud.localToGlobal(new Point(Global.hud.x, Global.hud.y)).x;
                this.x = (_local2.x - _local3);
                this.y = _local2.y;
            };
        }
        override public function close():void{
            this.m_building.setShowUpgradeArrow(false);
            this.m_building.setState(this.m_building.getState());
            dispatchEvent(new Event(Event.CLOSE));
            onHide();
        }

    }
}//package Display.UpgradesUI 
